import Tools from '../../../../utils/Tools.ts';
import { Text, View } from 'native-base';
import { CommonStyle } from '../../../../common/commonStyle.ts';
import React from 'react';
import AntDesign from 'react-native-vector-icons/AntDesign';

export default function RenderingDiscount(item: IProductInformation, shoppingCart: IProductInformation[], fontSize?: number) {
  if (Tools.hasActiveRange(item, shoppingCart)) {
    return (
      <View borderRadius={2} width={110} height={5} flexDirection={'row'} alignItems={'center'} paddingX={1} color={'#eb5449'} borderWidth={0.5} borderColor={CommonStyle.price}>
        <AntDesign name={'tago'} color={CommonStyle.price} />

        <Text marginLeft={1} fontSize={fontSize || 10} color={CommonStyle.price}>
          {((item.active.activePrice / item.price) * 10).toFixed(2)}折，限{item.active.maxNum}份
        </Text>
      </View>
    );
  } else if (item.salePrice !== item.price) {
    return (
      <View borderRadius={2} width={70} height={5} flexDirection={'row'} alignItems={'center'} paddingX={1} color={'#eb5449'} borderWidth={0.5} borderColor={CommonStyle.price}>
        <AntDesign name={'tago'} color={CommonStyle.price} />

        <Text marginLeft={1} fontSize={fontSize || 10} color={CommonStyle.price}>
          {((item.salePrice / item.price) * 10).toFixed(2)}折
        </Text>
      </View>
    );
  }
}
